package com.wangzhan.springboot.controller;


import com.wangzhan.springboot.model.User;
import org.springframework.web.bind.annotation.*;


//通过浏览器访问的方式是get请求
//@PutMapping修改操作可以用@PostMapping代替
//@DeleteMapping删除操作可以用@GetMapping代替

@RestController     // @RestController = @Controller + @ResponseBody,只能放回字符串或json
public class MVCController {

    @RequestMapping("/boot/getUser1")
    public Object getUser1(){
        User user = new User();
        user.setId(100);
        user.setName("张三——使用@RequestMapping注解");

        return user;
    }

//    只支持get请求,与下面的getUser2()是等价的
//    @GetMapping = @RequestMapping + RequestMethod.GET
    @GetMapping("/boot/getUser2")
    public Object getUser2(){
        User user = new User();
        user.setId(100);
        user.setName("张三-使用@GetMapping注解");

        return user;
    }

//    只支持get请求
    @RequestMapping(value = "/boot/getUser3", method = RequestMethod.GET)
    public Object getUser3(){
        User user = new User();
        user.setId(100);
        user.setName("张三-使用@RequestMapping(value = ,method = )");

        return user;
    }
//    只支持Post请求
//    @PostMapping = @RequestMapping + RequestMethod.POST
    @PostMapping("/boot/getUser4")
    public Object getUser4(){
        User user = new User();
        user.setId(100);
        user.setName("张三-使用@PostMapping注解");

        return user;
    }




}
